Computer software is often used to create systems that need to remain in “consistent” states. For example, computer software may implement a banking system that is composed of bank accounts. When a money transfer occurs from one bank account to another, the total amount of funds in the two accounts must remain equal before and after the transfer. Otherwise, something went wrong during the transfer and the banking system becomes inconsistent. In regards to a money transfer, the banking system would be considered consistent before the transfer is initiated or after the transfer successfully completes, and not during intermediate steps during the transfer process. That is, all steps of the money transfer—first debiting from the source account and second crediting to the destination account—must be completed, or none of the steps must be completed, for the banking system to remain in a consistent state.
A system is considered “consistent” if it maintains a predefined variant property for that system, as pertaining to a transaction. For a money transfer in a banking system, the variant property is that the total funds of source and destination accounts remain the same before and after the money transfer. One cause that may lead a system to be in an inconsistent, intermediate state is a power failure in the course of a transaction.
A sequence of steps that must all occur or none occur is referred in the art a “transaction,” because similarly to a banking transaction, these steps have consistent initial and final steps, but inconsistent intermediate steps. A sequence of steps that must all occur or none occur is also referred in the art as a sequence of steps that must occur “atomically.” Thus, the terms “atomic” and “transaction” are herein used to indicate the same concepts and will be used synonymously within the present disclosure.
Recently, devices that use non-volatile memory (NVM) have begun to see increased usage. Memory is where programs and data are kept when the processor is actively using them. Volatile or non-persistent memory is memory that needs constant power in order to prevent data from being erased. Volatile memory describes conventional memory, such as dynamic random access memory (DRAM). NVM is memory that is persistent (non-volatile). Non-volatile memory is memory that retains its data after having power cycled (turned off and then back on). Non-volatile memory is byte-addressable, random access non-volatile memory.
NVM presents new challenges in maintaining consistency of systems when transactions are interrupted, such as by power failures. One challenge is that the system may have been stored in NVM in an inconsistent state at the time of power loss, and when the power returns, the system is unable to continue from the precise point it left off. A second challenge is that caches used along with NVM are usually volatile. Changes to data within a cache need to be flushed to NVM for them to be recorded within memory. To flush data from a cache to memory means to copy contents of cache lines containing that data into memory, and then to evict those cache lines from the cache. Power loss may occur after changes were made but before some changes were flushed, resulting in a loss of data. The loss of data may leave the system in an inconsistent state.
To facilitate understanding, identical reference numerals have been used, where possible, to designate identical elements that are common to the figures. It is contemplated that elements disclosed in one embodiment may be beneficially utilized on other embodiments without specific recitation.